package com.pirestupppai.utils;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.blog.www.guideview.Component;
import com.pirestupppai.common.Constant;

/**
 *  引导
 */
public class GuideComponent implements Component {
    private Context mContext;
    private String mTipStr;
    private int mAnchorDirection;    // 引导文字相对选中文字的方向
    private int mFitDirection;       // 引导文字水平方向的开始方向
    private int mXOffset;
    private int mYOffset;

    public GuideComponent(Context context, String tipStr, int anchorDirection, int fitDirection, int xOffset, int yOffset) {
        this.mContext = context;
        this.mTipStr = tipStr;
        this.mAnchorDirection = anchorDirection;
        this.mFitDirection = fitDirection;
        this.mXOffset = xOffset;
        this.mYOffset = yOffset;
    }

    @Override
    public View getView(LayoutInflater inflater) {

        TextView tipTv = new TextView(mContext);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        tipTv.setText(mTipStr);
        tipTv.setTextColor(Color.parseColor("#FFFFFF"));
        tipTv.setTextSize(18);
        layoutParams.setMargins(Constant.WIDTH_OF_SCREEN / 2, 0, 0, 0);
        tipTv.setLayoutParams(layoutParams);
        return tipTv;
    }

    @Override
    public int getAnchor() {
        return mAnchorDirection;
    }

    @Override
    public int getFitPosition() {
        return mFitDirection;
    }

    @Override
    public int getXOffset() {
        return mXOffset;
    }

    @Override
    public int getYOffset() {
        return mYOffset;
    }
}
